<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category   Mage
 * @package    default_default
 * @copyright  Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
 * @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>
<?php $_items = $this->getItems(); ?>
<?php if($this->helper('giftmessage/message')->getIsMessagesAvailable('main', $this->getQuote(), $this->getStoreId()) || $_items): ?>
<div class="clear"></div>
<div class="giftmessage-order-create">
    <div class="entry-edit">
        <div class="entry-edit-head">
            <h4 class="fieldset-legend head-gift-message"><?php echo Mage::helper('sales')->__('Gift Message') ?></h4>
        </div>
        <div class="fieldset">
            <div class="box-left">
                <?php if($this->helper('giftmessage/message')->getIsMessagesAvailable('main', $this->getQuote(), $this->getStoreId())): ?>
                    <div class="entire-order">
                        <h5><?php echo Mage::helper('sales')->__('Add a gift message for the <strong>entire order</strong>') ?></h5>
                        <?php echo $this->getFormHtml($this->getQuote(), 'main') ?>
                    </div>
                <?php endif; ?>
            </div>
            <div class="box-right">
                <?php if ($_items): ?>
                    <div class="each-order-item">
                        <h5 class="section-head"><?php echo Mage::helper('sales')->__('Add a gift message for <strong>each gift item</strong>') ?></h5>
                        <div class="scroll">
                            <?php foreach ($_items as $_item): ?>
                                <h6><?php echo $_item->getName() ?></h6>
                                <?php echo $this->getFormHtml($_item, 'item'); ?>
                            <?php endforeach; ?>
                        </div>
                    </div>
                <?php endif ?>
            </div>
            <div class="clear"></div>
        </div>
    </div>
</div>
<script type="text/javascript">
//<![CDATA[
if(!window.toogleRequired) {
    var toogleRequired = function (source, objects)
    {
        if(!$(source).value.blank()) {
            objects.each(function(item) {
               $(item).addClassName('required-entry');
            });
        } else {
            objects.each(function(item) {
                if(editForm && editForm.validator) {
                   editForm.validator.reset(item);
                }
                $(item).removeClassName('required-entry');
            });
        }
    }
}
order.giftmessageFieldsBind('order-giftmessage');
//]]>
</script>
<?php endif; ?>
